package com.xwintop.xTransfer.receiver.bean;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: ReceiverConfigFtpServer
 * @Description: Ftp服务器接收器配置
 * @author: xufeng
 * @date: 2018/4/9 11:25
 */

@Data
public class ReceiverConfigFtpServer implements ReceiverConfig {
    private String serviceName = "receiverFtpServer";//对应服务名称
    private String id;//如果留空则系统自动分配
    private boolean enable = true;//是否开启
    private boolean async = false;//是否异步执行
    private boolean exceptionExit = false;//是否发生异常时退出任务

    private int port = 21;              //侦听器将接受连接的端口

    private String keystoreFilePath;//密钥存储文件的路径
    private String keystorePassword;//密钥库的密码

    private int maxLogins = 10;//最大登录,最大并发用户数
    private int maxAnonymousLogins = 10;//最大匿名登录,最大同时匿名用户数
    private int maxLoginFailures = 3;//最大登录失败,连接关闭前登录尝试失败的次数
    private int loginFailureDelay = 500;//登录失败延迟,登录尝试失败后连接延迟的毫秒数。用于限制暴力猜测密码的可能性。
    private int maxThreads = 0;//最大线程数,线程池中用于处理客户端连接的最大线程数
    private boolean anonymousLoginEnabled = false;//是否启用匿名登录
    private String anonymousHomeDirectory;//匿名用户目录路径

    private int timeout = 300000;       //Ftp服务器超时限制，单位为毫秒
    private int socketTimeout = 300000; //Socket连接超时限制，单位为毫秒；用于FTP服务器未知的情况，避免接收器长时间无响应；非特别情况下无需指定
    private boolean passive = false;    //连接模式：主动式和被动式；缺省为主动式
    private Integer fileType; //文件传输方式（设置除二进制、ACSII方式之外的传输方式）
    private Integer bufferSize; //缓冲数据流缓冲区大小
    private String serversEncoding = "AUTO";//编码格式

    private List<FtpServerUser> ftpServerUserList = new ArrayList<>();

    @Data
    public static class FtpServerUser implements Serializable {
        private String name = null;
        private String password = null;
        private int maxIdleTimeSec = 0; // no limit
        private String homeDir = null;
        private boolean isEnabled = true;
        private boolean downFile = true;
        private boolean upFile = true;
        private boolean deleteFile = true;
    }
}
